<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>积分排行榜</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <%@include file="../include/commonFile.jsp" %>
</head>
<body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">

            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <div class="layui-tab-content">
                    <form class="layui-form" action="${ctx}/member/integral/userIntegral/leaderboardList.do"
                          id="myForm" method="post">
                        <input type="hidden" name="typeId" id="typeId" value="${typeId}"/>
                        <input type="hidden" name="pageNo" id="pageNo"/>
                        <div class="f-search-bar">
                            <div class="search-container">
                                <ul class="search-form-content">
                                    <li class="form-item-inline"><label class="search-form-lable">积分类型：</label>
                                        <div class="layui-input-inline">
                                            <select name="cIntegralTypeId">
                                                <option value="">全部</option>
                                                <c:forEach var="cIntegralType" items="${cIntegralTypes}">
                                                    <c:if test="${cIntegralType.id == input.cIntegralTypeId}">
                                                        <option value="${cIntegralType.id}" selected="selected">${cIntegralType.name}</option>
                                                    </c:if>
                                                    <c:if test="${cIntegralType.id != input.cIntegralTypeId}">
                                                        <option value="${cIntegralType.id}">${cIntegralType.name}</option>
                                                    </c:if>
                                                </c:forEach>
                                            </select>
                                        </div>
                                    </li>
                                    <li class="form-item-inline"><label class="search-form-lable">昵称：</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="nickName" autocomplete="off" class="layui-input" value="${input.nickName}" placeholder="请输入查询昵称">
                                        </div>
                                    </li>
                                    <li class="form-item-inline"><label class="search-form-lable">手机号：</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="mobile" autocomplete="off" class="layui-input" value="${input.mobile}" placeholder="请输入查询手机号">
                                        </div>
                                    </li>
                                    <c:if test="${!isChild || isXzgsAdmin}">
                                        <li class="form-item-inline"><label class="search-form-lable">所属机构</label>
                                            <div class="layui-input-inline">
                                                <select name="memberGroupId">
                                                    <option value="">全部</option>
                                                    <c:forEach var="memberGroup" items="${memberGroupList}">
                                                        <option value="${memberGroup.id}" ${memberGroupId == memberGroup.id ? 'selected="selected"' : ''}>${memberGroup.realname}</option>
                                                    </c:forEach>
                                                </select>
                                            </div>
                                        </li>
                                    </c:if>
                                </ul>
                                <ul class="search-form-content">
                                    <li class="form-item"><label class="search-form-lable">排行类型：</label>
                                        <div class="check-btn-inner">
                                            <a href="javascript:void(0);" onclick="setTimeType($(this),0,'#myForm')" ${empty input.leaderBoardType || input.leaderBoardType == 0 ? 'class="active"' : ''}>行动力</a>
                                            <a href="javascript:void(0);" onclick="setTimeType($(this),1,'#myForm')" ${input.leaderBoardType == 1 ? 'class="active"' : ''}>影响力</a>
                                            <input type="hidden" name="leaderBoardType" value="${input.leaderBoardType}"/>
                                        </div>
                                    </li>
                                </ul>
                                <ul class="search-form-content">
                                    <li class="form-item"><label class="search-form-lable">排行时间：</label>
                                        <div class="check-btn-inner">
                                            <a id="all" href="javascript:void(0);" onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                            <a href="javascript:void(0);" onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>本月</a>
                                            <a href="javascript:void(0);" onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本季</a>
                                            <a href="javascript:void(0);" onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本年</a>
                                            <input type="hidden" name="timeType" value="${input.timeType}"/>
                                        </div>
                                        <div class="layui-inline">
                                            <div class="layui-input-inline">
                                                <input class="layui-input" type="text" name="createStart" value="${input.createStart}" placeholder="开始日">
                                            </div>
                                            -
                                            <div class="layui-input-inline">
                                                <input class="layui-input" type="text" name="createEnd" value="${input.createEnd}" placeholder="截止日">
                                            </div>
                                        </div>
                                    </li>
                                    <li class="form-item-inline">
                                        <div class="sub-btns">
                                            <a class="layui-btn layui-btn-danger"
                                               href="javascript:txz.expireCheck('', function() { exportExcelData() })">导出EXCEL</a>
                                            <a class="layui-btn layui-btn-danger" href="javascript:submitFunction('#myForm')">查询</a>
                                            <a class="layui-btn layui-btn-normal" href="javascript:resetFunction('#myForm')">重置</a>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </form>
                    <div class="my-act-list-content">
                        <ul id="view">
                            <table class="layui-table">
                                <colgroup>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <c:if test="${!isChild || isXzgsAdmin}">
                                        <col>
                                    </c:if>
                                    <col>
                                </colgroup>
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>排名</th>
                                    <th>昵称</th>
                                    <th>手机号</th>
                                    <th>获得积分</th>
                                    <c:if test="${!isChild || isXzgsAdmin}">
                                        <th>所属机构</th>
                                    </c:if>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach var="member" items="${list}" varStatus="st">
                                    <tr>
                                        <td>${page.limit * (page.page-1) + st.count}</td>
                                        <td>${member.ranking}</td>
                                        <td class="table-member"
                                            onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${member.memberId}','400px','470px')">
                                            <div class="member-cell">
                                                <div class="member-logo common-img"
                                                >
                                                    <img src="<c:if test="${ member.logo!= null}">${member.logo}?imageMogr2/auto-orient/crop/126x126</c:if>"
                                                         alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                                </div>
                                                <div class="member-name ellipsis-1"><a class="blue"
                                                                                       title="${member.name}"
                                                                                       href="javascript:void(0);">${member.name}</a>
                                                </div>
                                            </div>
                                        </td>
                                        <td>${member.mobile}</td>
                                        <td>${member.fraction == null? 0.0:member.fraction}</td>
                                        <c:if test="${!isChild || isXzgsAdmin}">
                                            <td>${member.partnerName}</td>
                                        </c:if>
                                        <td class="opts-btns tb-opts">
                                            <div class="comm-opts">
                                                <c:choose>
                                                    <c:when test="${input.leaderBoardType == 1}">
                                                        <a class="green"
                                                           href="${ctx}/member/integral/userIntegral/recommendPersonList.do?pmId=${member.pmId}&cIntegralTypeId=${input.cIntegralTypeId}&createStart=${input.createStart}&createEnd=${input.createEnd}">
                                                            查看推荐人
                                                        </a>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <a class="green"
                                                           href="${ctx}/member/integral/userIntegral/list.do?pmId=${member.pmId}&cIntegralTypeId=${input.cIntegralTypeId}&createStart=${input.createStart}&createEnd=${input.createEnd}">
                                                            查看积分
                                                        </a>
                                                    </c:otherwise>
                                                </c:choose>
                                            </div>
                                        </td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                        </ul>
                    </div>
                    <div id="page_content" class="page-container"></div>
                </div>
            </div>
        </div><!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">
    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });
        layui.use(['laydate'], function () {
            var laydate = layui.laydate;
            var start = {
                elem: 'input[name=createStart]'
            };
            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });
    })
    function exportExcelData() {
        layer.confirm('确认要导出Excel吗?', {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            var url = "${ctx}/member/integral/userIntegral/listExport.do";
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post(url, $("#myForm").serialize(), function (res) {
                top.layer.close(loadIndex);
                if (res.success) {
                    window.location.href = res.data;
                } else {
                    util.layerMsgError(res.description)
                }
            });
            top.layer.close(index);
        });
    }
</script>
<script type="text/javascript">
    txz.initHeader({
        nav: [{
            name: '积分排行榜',
            curr: true
        }],
        info: '<span class="f18"><span class="f14">共<b>${page.totalCount}</b>条记录，总积分：<font class="active-red f20">${totalScore == null ? 0 :totalScore}</font</span>',
        btns: [ {
            name: '返回',
            href: 'javascript:history.back();',
            icon: 'back'
        }]
    });
</script>
</body>
</html>